<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.EditUsinaLocalizacaoTitle}"></h:outputText>
        </ui:define>
        <ui:define name="body">

            <h:form>
                <p:growl id="messages" life="3000"/>

                <h:panelGroup id="messagePanel" styleClass="ajustaListaMensagemErro"  layout="block">
                    <h:messages errorStyle="color: red" infoStyle="color: green" layout="list"/>
                </h:panelGroup>

                <p:panel>
                    <f:facet name="header">
                        <h:outputText value="#{bundle.UsinaLocalizacaoTitle}"/>
                    </f:facet>

                    <h:panelGrid columns="2">
                        <h:outputLabel value="#{bundle.EditUsinaLocalizacaoLabel_uslId}" for="uslId" />
                        <p:inplace id="basic" >
                            <p:inputText id="uslId" readonly="true" value="#{usinaLocalizacaoController.selected.uslId}" title="#{bundle.EditUsinaLocalizacaoTitle_uslId}" required="true" requiredMessage="#{bundle.EditUsinaLocalizacaoRequiredMessage_uslId}"/>
                        </p:inplace>
                        <h:outputLabel value="#{bundle.EditUsinaLocalizacaoLabel_uslUsiId}" for="uslUsiId" />
                        <h:selectOneMenu id="uslUsiId" value="#{usinaLocalizacaoController.selected.uslUsiId}" title="#{bundle.EditUsinaLocalizacaoTitle_uslUsiId}" required="true" requiredMessage="#{bundle.EditUsinaLocalizacaoRequiredMessage_uslUsiId}">
                            <f:selectItems value="#{usinaController.itemsAvailableSelectOne}"/>
                            <p:focus for="uslUsiId"/>
                        </h:selectOneMenu>

                        <h:outputLabel value="#{bundle.EditUsinaLocalizacaoLabel_uslUfdCd}" for="uslUfdCd" />
                        <h:selectOneMenu id="uslUfdCd" value="#{usinaLocalizacaoController.selected.uslUfdCd}" required="true" requiredMessage="#{bundle.EditUsinaLocalizacaoRequiredMessage_uslUfdCd}">                            
                            <f:selectItems value="#{unidadeFederacaoController.itemsAvailableSelectOne}" />
                            <p:ajax update="uslMunCd"
                                    listener="#{usinaLocalizacaoController.carregaMunicipios}" />
                        </h:selectOneMenu>

                        <h:outputLabel value="#{bundle.EditUsinaLocalizacaoLabel_uslMunCd}" for="uslMunCd" />
                        <h:selectOneMenu  id="uslMunCd" value="#{usinaLocalizacaoController.selected.uslMunCd}" title="#{bundle.EditUsinaLocalizacaoTitle_uslMunCd}" >
                            <f:selectItems value="#{usinaLocalizacaoController.itemsAvailableSelectOneMunicipioByUf}"/>
                        </h:selectOneMenu>

                        <h:outputLabel value="#{bundle.EditUsinaLocalizacaoLabel_subbacia}" for="subbacia" />
                        <h:selectOneMenu id="subbacia" value="#{usinaLocalizacaoController.subbacia}" title="#{bundle.EditUsinaLocalizacaoTitle_subbacia}" >
                            <f:selectItems value="#{subbaciaController.itemsAvailableSelectOne}"/>
                            <p:ajax update="uslRioCd" listener="#{usinaLocalizacaoController.carregaRios}"/>
                        </h:selectOneMenu>                       

                        <h:outputLabel value="#{bundle.EditUsinaLocalizacaoLabel_uslRioCd}" for="uslRioCd" />
                        <h:selectOneMenu id="uslRioCd" required="true" requiredMessage="#{bundle.EditUsinaLocalizacaoRequiredMessage_uslRioCd}"  value="#{usinaLocalizacaoController.selected.uslRioCd}" title="#{bundle.EditUsinaLocalizacaoTitle_uslRioCd}" >
                            <f:selectItems value="#{usinaLocalizacaoController.itemsAvailableSelectOneRiosBySubbacia}"/>
                        </h:selectOneMenu>

                    </h:panelGrid>

                    <p:commandButton ajax="false" icon="ui-icon-disk" action="#{usinaLocalizacaoController.update}" value="#{bundle.EditUsinaLocalizacaoSaveLink}"/> &nbsp;
                    <p:commandButton ajax="false" action="View" value="#{bundle.EditUsinaLocalizacaoViewLink}" immediate="true"/> &nbsp;
                    <p:commandButton ajax="false" action="#{usinaLocalizacaoController.prepareList}" value="#{bundle.EditUsinaLocalizacaoShowAllLink}" immediate="true"/>

                </p:panel>
            </h:form>
            <br/>
            <ui:include src="Lista.xhtml"/>
        </ui:define>

    </ui:composition>

</html>
